from abc import ABC

from tornado.web import RequestHandler
from views.ViewRouterInterface import ViewRouterInterface

"""
    Test view
"""


class TestHandler(ViewRouterInterface, RequestHandler, ABC):
    # 配置路由
    def configRouter(self):
        return [
            (r"/test", TestHandler)
        ]

    # Get方法
    def get(self):
        items = ["item1", "item2", "item3"]
        items2 = ["item1", "item2"]

        def checked(item):
            return 'checked=checked' if item in items2 else ''
        # 定义目录层级
        self.render("test/test.html", items=items, add=add, items2=items2, checked=checked)


"""
    Html Page Function
"""


def add(x, y):
    return x + y
